<!DOCTYPE HTML>
<html lang="zh-tw" >
    <!-- Start book django项目 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>认识RESTful | django项目</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-emphasize/plugin.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
    

        
    
    
    <link rel="next" href="../C01-IntroduceToDRF/HowToDesignREST.html" />
    
    
    <link rel="prev" href="../C01-IntroduceToDRF/SeparatedFrontendAndBackend.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="1.2"
        data-chapter-title="认识RESTful"
        data-filepath="C01-IntroduceToDRF/IntroduceToREST.md"
        data-basepath=".."
        data-revision="Sun Nov 18 2018 07:16:17 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        课程介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="C01-IntroduceToDRF/index.html">
            
                
                    <a href="../C01-IntroduceToDRF/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        引入DjangoRESTframework
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="C01-IntroduceToDRF/SeparatedFrontendAndBackend.html">
            
                
                    <a href="../C01-IntroduceToDRF/SeparatedFrontendAndBackend.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        Web应用模式
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="1.2" data-path="C01-IntroduceToDRF/IntroduceToREST.html">
            
                
                    <a href="../C01-IntroduceToDRF/IntroduceToREST.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        认识RESTful
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="C01-IntroduceToDRF/HowToDesignREST.html">
            
                
                    <a href="../C01-IntroduceToDRF/HowToDesignREST.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        RESTful设计方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="C01-IntroduceToDRF/DevelopRESTAPIWithDjango.html">
            
                
                    <a href="../C01-IntroduceToDRF/DevelopRESTAPIWithDjango.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        使用Django开发REST接口
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="C01-IntroduceToDRF/CoreTaskToDevelopRESTAPI.html">
            
                
                    <a href="../C01-IntroduceToDRF/CoreTaskToDevelopRESTAPI.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        明确REST接口开发的核心任务
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="C01-IntroduceToDRF/AboutDRF.html">
            
                
                    <a href="../C01-IntroduceToDRF/AboutDRF.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        DjangoRESTframework简介
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="C02-DRFProject/index.html">
            
                
                    <a href="../C02-DRFProject/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        DRF工程搭建
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="C02-DRFProject/InstallAndConfig.html">
            
                
                    <a href="../C02-DRFProject/InstallAndConfig.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        环境安装与配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="C02-DRFProject/TheFirstDRFProgram.html">
            
                
                    <a href="../C02-DRFProject/TheFirstDRFProgram.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        见识DRF的魅力
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="C03-Serializer/index.html">
            
                
                    <a href="../C03-Serializer/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Serializer序列化器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="C03-Serializer/Declaring.html">
            
                
                    <a href="../C03-Serializer/Declaring.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        定义Serializer
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="C03-Serializer/Serializing.html">
            
                
                    <a href="../C03-Serializer/Serializing.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        序列化使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="C03-Serializer/Deserializing.html">
            
                
                    <a href="../C03-Serializer/Deserializing.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        反序列化使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="C03-Serializer/ModelSerializer.html">
            
                
                    <a href="../C03-Serializer/ModelSerializer.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        模型类序列化器ModelSerializer
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="C04-View/index.html">
            
                
                    <a href="../C04-View/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        视图
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="C04-View/RequestAndResponse.html">
            
                
                    <a href="../C04-View/RequestAndResponse.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        Request与Response
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="C04-View/View.html">
            
                
                    <a href="../C04-View/View.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        视图概览
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="C04-View/ViewIntroduction.html">
            
                
                    <a href="../C04-View/ViewIntroduction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        视图说明
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="C04-View/ViewSet.html">
            
                
                    <a href="../C04-View/ViewSet.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        视图集ViewSet
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="C04-View/Routers.html">
            
                
                    <a href="../C04-View/Routers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        路由Router
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="C05-Components/index.html">
            
                
                    <a href="../C05-Components/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        其他功能
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="C05-Components/Authentication.html">
            
                
                    <a href="../C05-Components/Authentication.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        认证
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="C05-Components/Permissions.html">
            
                
                    <a href="../C05-Components/Permissions.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        权限
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="C05-Components/Throttling.html">
            
                
                    <a href="../C05-Components/Throttling.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        限流
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="C05-Components/Filtering.html">
            
                
                    <a href="../C05-Components/Filtering.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        过滤
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="C05-Components/Ordering.html">
            
                
                    <a href="../C05-Components/Ordering.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="C05-Components/Pagination.html">
            
                
                    <a href="../C05-Components/Pagination.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        分页
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="C05-Components/Exceptions.html">
            
                
                    <a href="../C05-Components/Exceptions.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        异常处理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="C05-Components/Documents.html">
            
                
                    <a href="../C05-Components/Documents.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        自动生成接口文档
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本書使用 GitBook 釋出
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >django项目</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x8BA4;&#x8BC6;restful">&#x8BA4;&#x8BC6;RESTful</h1>
<p><strong>&#x5728;&#x524D;&#x540E;&#x7AEF;&#x5206;&#x79BB;&#x7684;&#x5E94;&#x7528;&#x6A21;&#x5F0F;&#x91CC;&#xFF0C;&#x540E;&#x7AEF;API&#x63A5;&#x53E3;&#x5982;&#x4F55;&#x5B9A;&#x4E49;&#xFF1F;</strong></p>
<ul>
<li><p>&#x5BF9;&#x4E8E;&#x63A5;&#x53E3;&#x7684;&#x8BF7;&#x6C42;&#x65B9;&#x5F0F;&#x4E0E;&#x8DEF;&#x5F84;&#xFF0C;&#x6BCF;&#x4E2A;&#x540E;&#x7AEF;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x53EF;&#x80FD;&#x90FD;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x5B9A;&#x4E49;&#x65B9;&#x5F0F;&#xFF0C;&#x98CE;&#x683C;&#x8FE5;&#x5F02;&#x3002;</p>
</li>
<li><p>&#x662F;&#x5426;&#x5B58;&#x5728;&#x4E00;&#x79CD;&#x7EDF;&#x4E00;&#x7684;&#x5B9A;&#x4E49;&#x65B9;&#x5F0F;&#xFF0C;&#x88AB;&#x5E7F;&#x5927;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x63A5;&#x53D7;&#x8BA4;&#x53EF;&#x7684;&#x65B9;&#x5F0F;&#x5462;&#xFF1F;</p>
</li>
<li><p>&#x8FD9;&#x5C31;&#x662F;&#x88AB;&#x666E;&#x904D;&#x91C7;&#x7528;&#x7684;API&#x7684;RESTful&#x8BBE;&#x8BA1;&#x98CE;&#x683C;&#x3002;</p>
</li>
<li><p>&#x4F8B;&#x5982;&#x5BF9;&#x4E8E;&#x540E;&#x7AEF;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x4FDD;&#x5B58;&#x4E86;&#x5546;&#x54C1;&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x524D;&#x7AEF;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x5BF9;&#x5546;&#x54C1;&#x6570;&#x636E;&#x8FDB;&#x884C;&#x589E;&#x5220;&#x6539;&#x67E5;&#xFF0C;&#x90A3;&#x76F8;&#x5E94;&#x7684;&#x6BCF;&#x4E2A;&#x64CD;&#x4F5C;&#x540E;&#x7AEF;&#x90FD;&#x9700;&#x8981;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;API&#x63A5;&#x53E3;&#xFF1A;</p>
</li>
</ul>
<table>
<thead>
<tr>
<th>&#x8BF7;&#x6C42;&#x65B9;&#x6CD5;</th>
<th>&#x8BF7;&#x6C42;&#x5730;&#x5740;</th>
<th>&#x540E;&#x7AEF;&#x64CD;&#x4F5C;</th>
</tr>
</thead>
<tbody>
<tr>
<td>GET</td>
<td>/goods</td>
<td>&#x83B7;&#x53D6;&#x6240;&#x6709;&#x5546;&#x54C1;</td>
</tr>
<tr>
<td>POST</td>
<td>/goods</td>
<td>&#x589E;&#x52A0;&#x5546;&#x54C1;</td>
</tr>
<tr>
<td>GET</td>
<td>/goods/1</td>
<td>&#x83B7;&#x53D6;&#x7F16;&#x53F7;&#x4E3A;1&#x7684;&#x5546;&#x54C1;</td>
</tr>
<tr>
<td>PUT</td>
<td>/goods/1</td>
<td>&#x4FEE;&#x6539;&#x7F16;&#x53F7;&#x4E3A;1&#x7684;&#x5546;&#x54C1;</td>
</tr>
<tr>
<td>DELETE</td>
<td>/goods/1</td>
<td>&#x5220;&#x9664;&#x7F16;&#x53F7;&#x4E3A;1&#x7684;&#x5546;&#x54C1;</td>
</tr>
</tbody>
</table>
<h2 id="&#x8D77;&#x6E90;">&#x8D77;&#x6E90;</h2>
<p>REST&#x8FD9;&#x4E2A;&#x8BCD;&#xFF0C;&#x662F;<a href="http://en.wikipedia.org/wiki/Roy_Fielding" target="_blank">Roy Thomas Fielding</a>&#x5728;&#x4ED6;2000&#x5E74;&#x7684;<a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm" target="_blank">&#x535A;&#x58EB;&#x8BBA;&#x6587;</a>&#x4E2D;&#x63D0;&#x51FA;&#x7684;&#x3002;</p>
<p><img src="../images/REST&#x4F5C;&#x8005;.jpg" alt="REST&#x4F5C;&#x8005;"></p>
<p>Fielding&#x662F;&#x4E00;&#x4E2A;&#x975E;&#x5E38;&#x91CD;&#x8981;&#x7684;&#x4EBA;&#xFF0C;&#x4ED6;&#x662F;HTTP&#x534F;&#x8BAE;&#xFF08;1.0&#x7248;&#x548C;1.1&#x7248;&#xFF09;&#x7684;&#x4E3B;&#x8981;&#x8BBE;&#x8BA1;&#x8005;&#x3001;Apache&#x670D;&#x52A1;&#x5668;&#x8F6F;&#x4EF6;&#x7684;&#x4F5C;&#x8005;&#x4E4B;&#x4E00;&#x3001;Apache&#x57FA;&#x91D1;&#x4F1A;&#x7684;&#x7B2C;&#x4E00;&#x4EFB;&#x4E3B;&#x5E2D;&#x3002;&#x6240;&#x4EE5;&#xFF0C;&#x4ED6;&#x7684;&#x8FD9;&#x7BC7;&#x8BBA;&#x6587;&#x4E00;&#x7ECF;&#x53D1;&#x8868;&#xFF0C;&#x5C31;&#x5F15;&#x8D77;&#x4E86;&#x5173;&#x6CE8;&#xFF0C;&#x5E76;&#x4E14;&#x7ACB;&#x5373;&#x5BF9;&#x4E92;&#x8054;&#x7F51;&#x5F00;&#x53D1;&#x4EA7;&#x751F;&#x4E86;&#x6DF1;&#x8FDC;&#x7684;&#x5F71;&#x54CD;&#x3002;</p>
<h2 id="&#x8BF4;&#x660E;">&#x8BF4;&#x660E;</h2>
<ul>
<li>RESTful&#x662F;&#x4E00;&#x79CD;&#x5F00;&#x53D1;&#x7406;&#x5FF5;&#x3002;<strong>REST</strong>&#x662F;<strong>&#x8BBE;&#x8BA1;&#x98CE;&#x683C;</strong>&#x800C;&#x4E0D;&#x662F;&#x6807;&#x51C6;&#x3002;</li>
<li>&#x516C;&#x53F8;&#x4E2D;&#x7684;&#x540E;&#x7AEF;&#x7A0B;&#x5E8F;&#x5458;&#x5728;&#x5B9A;&#x4E49;&#x540E;&#x7AEF;&#x7684;&#x63A5;&#x53E3;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x9009;&#x62E9;&#x662F;&#x5426;&#x9075;&#x5B88;&#x8FD9;&#x79CD;&#x8BBE;&#x8BA1;&#x98CE;&#x683C;&#x3002;</li>
<li>RESTful&#x8BBE;&#x8BA1;&#x98CE;&#x683C;&#x7684;API&#xFF0C;&#x6BCF;&#x79CD;&#x8BF7;&#x6C42;&#x65B9;&#x6CD5;&#xFF0C;&#x90FD;&#x5BF9;&#x5E94;&#x540E;&#x7AEF;&#x4E00;&#x79CD;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;&#x3002;</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../C01-IntroduceToDRF/SeparatedFrontendAndBackend.html" class="navigation navigation-prev " aria-label="Previous page: Web应用模式"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../C01-IntroduceToDRF/HowToDesignREST.html" class="navigation navigation-next " aria-label="Next page: RESTful设计方法"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"fontsettings":{"family":"sans","size":2,"theme":"white"},"toggle-chapters":{},"splitter":{},"emphasize":{},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book django项目 -->
</html>
